#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QProcess>
#include <QThread>
#include <iostream>
#include <festival/festival.h>

using namespace std;

class Speech : public QThread {
    Q_OBJECT
private:
  string text;
  int heap_size;
  int load_init_files;
public:
  Speech(string t="") : text(t), heap_size(2100000),load_init_files(1) {
  }

  void setText(string t) {
    text = t;
  }

  void run() {
    festival_initialize(load_init_files,heap_size);
    festival_say_text(text.c_str());
    festival_wait_for_spooler();
    emit resultReady("Done");
  }
signals:
    void resultReady(const QString &result);
};

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
  Q_OBJECT

public:
  explicit MainWindow(QWidget *parent = 0);
  ~MainWindow();

private:
  Ui::MainWindow *ui;
  Speech* speech;

private slots:
  void playText();
  void playFile();
};

#endif // MAINWINDOW_H
